<?php

//公钥加密方法
function RSAEncode($data){
    $public_key='-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApbOzo8K6i5hNf04ppfwGKYPowkLvenF5MyARVVc+ZL8/GrZpP2cJk+aSXVWxgVTiE6uvDxuUZrDlqcsbn1gcnp9Pn4/KEQt3gHWVwICcYclNyr6SvKdd0nJI/Deu41zqB+W4Ifbo05XWmv2QnUdUPWZfp/OuM5Yv0B4hmRH5Jer5FwnzQa/f/j65wy3OSozn8sKzP2RmACN/5Du3qq5nFWVK1oJ50T6JToBpm13Jva98eWD+ne2FUQpHJiLnig1pirUksQyBz2uNs/saYPFCx+blQW7IYq2wwN1jpgiRZVtf3YHONqbD3LuoVy3+og7alCys5ZYI5GcHEf08HJSW2wIDAQAB
-----END PUBLIC KEY-----';
    openssl_public_encrypt($data,$encode_result,$public_key); 
    return base64_encode($encode_result);
}

//私钥加密方法
function RSADecode($data){
    $private_key='-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEApbOzo8K6i5hNf04ppfwGKYPowkLvenF5MyARVVc+ZL8/GrZpP2cJk+aSXVWxgVTiE6uvDxuUZrDlqcsbn1gcnp9Pn4/KEQt3gHWVwICcYclNyr6SvKdd0nJI/Deu41zqB+W4Ifbo05XWmv2QnUdUPWZfp/OuM5Yv0B4hmRH5Jer5FwnzQa/f/j65wy3OSozn8sKzP2RmACN/5Du3qq5nFWVK1oJ50T6JToBpm13Jva98eWD+ne2FUQpHJiLnig1pirUksQyBz2uNs/saYPFCx+blQW7IYq2wwN1jpgiRZVtf3YHONqbD3LuoVy3+og7alCys5ZYI5GcHEf08HJSW2wIDAQABAoIBABDNtmvm9W/uk/1S+dpBQoa3P8VjcFGkbDwJBnj3Dfa9hjK5SNcLJed/vFwGsqeA6iRAhtIrY9M+ISwk0rpH/y7+zN5LgJxV41p9kiAharpn5aGnzc2f013iBRC+vNeFtp3yZ8fZ+CZszYSOLjok36ASX6Tyi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EY-----';
    openssl_private_decrypt(base64_decode($data),$decode_result,$private_key); 
    return $decode_result;

}

var_dump(RSAEncode("编辑框")); 
var_dump(RSADecode(RSAEncode("编辑框"))); 

?>